<template>
	<div class="userinfo weui-panel">
		<div class="weui-panel__hd" style="position: initial;">
			<div class="user_info">
				<div @click="goSee('3')" class="logo"><img style="width:99%" :src="logo" alt="admin"></div>
				<p style="margin-top: -5.625rem;" class="name" v-if="userInfo">姓名：{{userInfo.userInfo.name}}</p>
				<p class="name"> 职位：{{positionName}}</p>
			</div>
		</div>
		<div class="weui-panel" style="margin-top: 1.9375rem;">
			<div class="weui-panel__bd">
				<div class="weui-media-box weui-media-box_small-appmsg">
					<div class="weui-cells">
						<div v-if="userInfo.userInfo.position=='1'">
							<a class="weui-cell weui-cell_access" href="javascript:;">
								<div class="weui-cell__hd"><img
										src=""
										alt="" style="width:20px;margin-right:5px;display:block"></div>
								<div class="weui-cell__bd weui-cell_primary" @click="goSee('1')">
									<p>课程</p>
								</div>
								<span class="weui-cell__ft"></span>
							</a>
							<a class="weui-cell weui-cell_access" href="javascript:;">
								<div class="weui-cell__hd"><img
										src=""
										alt="" style="width:20px;margin-right:5px;display:block"></div>
								<div class="weui-cell__bd weui-cell_primary" @click="goSee('2')">
									<p>约课</p>
								</div>
								<span class="weui-cell__ft"></span>
							</a>
							
						</div>
						<!-- 管理员 -->
						<div v-else>

							<div class="weui-grids">
								<a href="javascript:" class="weui-grid" @click="goSee('A1')">
									<div class="weui-grid__icon">
										<img src="../../assets/img/manager/biaodan.png" alt="">
									</div>
									<p class="weui-grid__label">课程管理</p>
								</a>
								<a href="javascript:" class="weui-grid" @click="goSee('A2')">
									<div class="weui-grid__icon">
										<img src="../../assets/img/manager/riqi.png" alt="">
									</div>
									<p class="weui-grid__label">约课管理</p>
								</a>
								<a href="javascript:" class="weui-grid" @click="goSee('A3')">
									<div class="weui-grid__icon">
										<img src="../../assets/img/manager/ren.png" alt="">
									</div>
									<p class="weui-grid__label">员工管理</p>
								</a>
								<a href="javascript:" class="weui-grid" @click="goSee('A4')">
									<div class="weui-grid__icon">
										<img src="../../assets/img/manager/shezhi.png" alt="">
									</div>
									<p class="weui-grid__label">维护作业</p>
								</a>
								<a href="javascript:" class="weui-grid" @click="goSee('A5')">
									<div class="weui-grid__icon">
										<img src="../../assets/img/manager/shezhi.png" alt="">
									</div>
									<p class="weui-grid__label">系统设置</p>
								</a>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	import logoImg from "@/assets/img/1.jpeg";
	import constant from '@/utils/constant'
	export default {
		data() {
			return {
				userInfo: {},
				logo: logoImg,
			}
		},
		created() {
			this.userInfo = JSON.parse(localStorage.getItem("userInfo"));
			this.positionName = this.getPositionName(this.userInfo.userInfo.position);
		},
		methods: {
			//获取职位名称
			getPositionName(code) {
				let name = '';
				let position = constant.positionType;
				for (var i in position) {
					if (position[i].value == code) {
						name = position[i].label;
					}
				}
				return name;
			},
			//跳转
			goSee(type) {
				if (type == '1') {
					//查看本人名下课程
					this.$router.push({
						name: "techCase",
						params: {
							"account": this.userInfo.userInfo.account
						}
					});
				} else if (type == '2') {
					//查看约课记录
					this.$router.push({
						name: "techSKHis",
						params: {
							"account": this.userInfo.userInfo.account
						}
					});
				} else if (type == '3') {
					//本人信息页
					this.$router.push({
						name: "techUserInfoPage",
						params: {
							"account": this.userInfo.userInfo.account
						}
					});
				} else if (type == 'A1') {
					//查看约课记录
					this.$router.push({
						name: "techCase"
					});
				} else if (type == 'A2') {
					//查看约课记录
					this.$router.push({
						name: "techSKHis"
					});
				} else if (type == 'A3') {
					this.$router.push({name: "staffs"});
				} else if( type =='A4') {
					//维护作业
					this.$router.push({name:"maintainPage"})
				}
			}
		}
	}
</script>

<style scoped="scoped">
	.userinfo {
		background-color: #a1edee;
	}

	.i_icon {
		font-size: 20px;
		color: #b9b9b9;
		cursor: pointer;
	}

	.logo {
		/* display: inline-block; */
		margin: 0.3125rem;
		width: 5.25rem;
		height: 5.25rem;
		border-radius: 5.25rem;
		-webkie-border-radius: 5.25rem;
		-moz-border-radius: 5.25rem;
		border: 0.125rem solid #fff;
		box-shadow: 0 0 0.25rem #ccc;
		overflow: hidden;
	}

	.name {
		margin-left: 6.725rem;
	}
</style>
